import { RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import AppLayout from '@/layout/AppLayout.vue'

// 路由规则
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'AppLayout',
    component: AppLayout,
    children: [
      {
        path: '/data/:id',
        name: 'home',
        component: () => import('@/views/home.vue'),
        meta: { title: '首页' },
      }
    ],
  }
]

const router = createRouter({
  history: createWebHashHistory(), // 路由模式
  routes,
})

router.beforeEach(() => {
  nprogress.start()
})

router.afterEach(() => {
  nprogress.done()
})

export default router
